<template>
    <view class="bian_content" :class="[varClass, isBg ? 'bian_bg' : '', isBackgroudWhite ? 'is-backgroud-white' : '']">
        <image v-if="isBg" class="bian_icon_img" src="/static/images/icon/icon2.png" />
        <view class="title" v-if="title">
            <image class="title_img" src="/static/images/icon/icon01.png" />
            <text class="title_text">{{ title }}</text>
        </view>
        <view class="title_content">
            <view class="con"> {{ item.content }}</view>
            <view class="empty" v-if="!isIndex"></view>
        </view>
        <view class="idea_list">
            <view class="zheng">
                <view class="inner">
                    <view class="bx" @click="toDebateDetailItem(item.id)">
                        <view class="top_t">
                            <text class="top_c">正方</text>
                            <view class="top_t_num">
                                <text>{{ item.prosRatio }}</text><text class="per">%</text>
                            </view>
                        </view>
                        <view class="center_t">{{ item.prosTitle }}</view>
                        <view class="m_t">
                            <view class="text">支持者</view>
                            <view class="num">{{ item.prosUserNum }}</view>
                        </view>
                    </view>
                    <view class="bottom_t"><text class="icon-zan" @click="supportHandle(1, item.id)">支持正方</text></view>
                </view>
            </view>
            <view class="fan">
                <view class="inner">
                    <view class="bx" @click="toDebateDetailItem(item.id)">
                        <view class="top_t">
                            <view class="top_t_num">
                                <text>{{ item.consRatio }}</text><text>%</text>
                            </view>
                            <text class="top_c">反方</text>
                        </view>
                        <view class="center_t">{{ item.consTitle }}</view>
                        <view class="m_t">
                            <view class="num">{{ item.consUserNum }}</view>
                            <view class="text">支持者</view>
                        </view>
                    </view>
                    <view class="bottom_t"><text class="icon-zan" @click="supportHandle(0, item.id)">支持反方</text></view>
                </view>
            </view>
        </view>

        <slot name="operate"></slot>
    </view>
</template>

<script setup lang="ts">
import type { IDebatehallListResult } from '@/types/debatehall'

// 定义 emits
const emit = defineEmits(['supportHandle'])

const props = withDefaults(
    defineProps<{
        isNotDetail?: boolean,
        varClass?: string,
        isIndex?: boolean,
        isBg?: boolean,
        isBackgroudWhite?: boolean,
        title?: string,
        item: IDebatehallListResult,

    }>(),
    {
        isNotDetail: false,
        isIndex: true,
        isBg: true,
        isBackgroudWhite: false,
        title: '',
        varClass: 'default-class', // 默认值
    }
)

const toDebateDetailItem = (id: number) => {
    if (!props.isNotDetail) {
        return;
    }
    uni.navigateTo({
        url: '/pages/debatehall/detail?id=' + id
    })
}

const supportHandle = (type: number, debateId: number) => {
    emit('supportHandle', type, debateId)
}

</script>

<style lang="scss">
@import '@/styles/style-variables.scss';



.bian_content {
    display: flex;
    flex-direction: column;
    background-color: $background-white-color;
    border-radius: 10rpx;
    margin-top: 50rpx;
    padding: 30rpx;
    position: relative;

    .bian_icon_img {
        position: absolute;
        right: -30rpx;
        top: -30rpx;
        width: 150rpx;
        height: 150rpx;
    }

    &.bian_bg {
        background: linear-gradient(to bottom,
                rgba(255, 255, 0, 0.05),
                rgba(247, 247, 244, 0.05),
                rgba(255, 0, 0, 0.05)) 0 0;
        background-size: 100% 100%;
        background-repeat: no-repeat;

    }

    &.is-backgroud-white {
        background: white;
        margin-top: 0;
        padding: 0;
        border-radius: 0;

        .bian_icon_img {
            right: 0;

        }
    }



    .title {
        display: flex;
        align-items: center;
        margin-bottom: 12rpx;
        justify-content: center;
        padding-bottom: 30rpx;

        .title_img {
            width: 32rpx;
            height: 32rpx;
            margin-right: 8px;
        }

        .title_text {
            font-size: 30rpx;
            font-weight: $font-bold-weight;
            color: $font-title-color;
        }
    }

    .title_content {
        display: flex;
        flex-direction: row;

        .con {
            flex: 1;
            padding: 0 60rpx;
            font-size: 30rpx;
            @include two-index-ellipsis-style(3);
        }

        .empty {
            width: 50rpx;
        }
    }

    .idea_list {
        padding: 16px;
        display: flex;
        gap: 40rpx;


        .zheng,
        .fan {
            // width: 300rpx;
            height: 405rpx;
            background: linear-gradient(180deg, #FFE684 0%, #F4C236 100%);
            background-color: #fff;
            border-radius: 20rpx;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 8rpx;

            flex: 1;


            height: 405rpx;
            background-color: #fff;

            .inner {
                width: 100%;
                height: 100%;
                box-sizing: border-box;
                background-color: #fff;
                border-radius: 20rpx;
                display: flex;
                flex-direction: column;

                .bx {
                    display: flex;
                    flex-direction: column;
                }
            }
        }

        .fan {
            background: linear-gradient(180deg, #7298FD 0%, #2F5AD0 100%);
        }



        .zheng,
        .fan {

            .top_t {
                display: flex;
                justify-content: space-between;
                align-items: center;


                .top_c {
                    font-size: $font-size;
                    font-weight: bold;
                    color: $font-title-color;
                    text-align: center;
                    flex: 1;
                }

                .top_t_num {
                    flex: 1;
                    height: 76rpx;
                    // background: linear-gradient(240deg, #FFE684 0%, # 100%);
                    font-size: 44rpx;
                    color: #fff;
                    font-weight: 500;


                    text {
                        margin-left: 4px;

                        &.per {
                            font-weight: 300;
                            margin-left: 0rpx;
                        }
                    }
                }
            }

            .center_t {
                font-size: 26rpx;
                color: $font-title-color;
                margin-bottom: 12px;
                line-height: 1.5;
                margin: 30rpx 20rpx 0;

                @include two-ellipsis-style();
            }

            .m_t {
                display: flex;
                justify-content: space-between;
                align-items: flex-end;
                padding: 0 20rpx;

                .num {
                    color: #1A1A1A;
                    font-weight: 700;
                    font-size: 44rpx;
                }

                .text {
                    color: #7B7B7B;
                    font-size: 25rpx;
                    padding-bottom: 6rpx;
                }
            }

            .bottom_t {
                width: 223rpx;
                height: 76rpx;
                background: #F6C53E;
                border-radius: 10rpx;
                margin: auto;
                display: flex;
                align-items: center;
                justify-content: center;

                .icon-zan {
                    font-size: $font-size;
                    color: #fff;

                    &::before {
                        content: "\ec8c";
                        font-family: 'iconfont' !important;
                        color: #fff;
                        font-size: 38rpx;
                        margin-right: 4rpx;
                    }
                }
            }
        }

        .zheng {
            .top_t {
                .top_t_num {
                    background: linear-gradient(240deg, #F4C236 0%, #F4C236 100%);
                    border-top-right-radius: 10px;
                    border-bottom-left-radius: 20px;
                }
            }
        }

        .fan {
            .top_t {
                .top_t_num {
                    border-top-left-radius: 10px;
                    border-bottom-right-radius: 20px;
                    background: linear-gradient(240deg, #2F5AD0 0%, #2F5AD0 100%);
                }
            }

            .bottom_t {
                background-color: #2F5AD0;
            }
        }
    }
}
</style>